package com.KeyWord.equals_.Exercise;

public class Exercise_ {
    public static void main(String[] args) {
        //重写equals方法
        Person person1 = new Person('男',"Moose",90);
        Person person2 = new Person('男',"Moose",90);
        System.out.println(person1.equals(person2));

        //这里比较的是地址，但是我们想让它比较属性
        //if(传进来的对象 instanceof Person){
        //    if(传进来的对象





    }
}

class Person {

    private String name;
    private int age;
    private  char gender;

    public Person(char gender, String name, int age) {
        this.gender = gender;
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public char getGender() {
        return gender;
    }

    public void setGender(char gender) {
        this.gender = gender;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public boolean equals(Object obj){
        if(this == obj){
            return true;
        }
        if(obj instanceof Person){
            Person person = (Person)obj;
            return name.equals(person.getName()) && age == person.getAge() && gender == person.getGender();
        }
        return false;
    }
}








